<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>欢迎使用电子商务管理系统  版权所有@重庆旭鸣信息工程有限公司</title>
    <jsp:include page="include/base.jsp"></jsp:include>
    <jsp:include page="include/common.jsp"></jsp:include>
    <script type="text/javascript" src="web/LoginHandler.js"></script>
  </head>
  <body>
  	<div id="loginWindow" class="mini-window" title="用户登录" style="width:350px;height:186px;" 
   		showModal="true" showCloseButton="false">
	    <div id="loginForm" style="padding:15px;padding-top:10px;border:0px solid;">
	        <table align="center" cellpadding="8">
	            <tr>
	                <td style="width:60px;"><label for="username$text">帐号：</label></td>
	                <td>
	                    <input id="userId" name="userId" onvalidation="onUserNameValidation" class="mini-textbox" required="true" style="width:180px;" value="superman"/>
	                </td>    
	            </tr>
	            <tr>
	                <td style="width:60px;"><label for="pwd$text">密码：</label></td>
	                <td>
	                    <input id="password" name="password" onvalidation="onPwdValidation" class="mini-password" requiredErrorText="密码不能为空" required="true" style="width:180px;" value="xuminginfo"/>
	                </td>
	            </tr>            
	            <tr>
	            	<td>&nbsp;</td>
	                <td style="padding-top:5px;">
	                    <a onclick="LoginHandler.login" class="mini-button" style="width:50px;">登录</a>&nbsp;
	                    <a onclick="onResetClick" class="mini-button" style="width:50px;">重置</a>
	                </td>
	            </tr>
	        </table>
	    </div>
	</div>
	<div id="htmlContent" style="padding-left:10px;display:none;">正在登录中，请稍后...
		<div style="background:url('resource/miniui/themes/icons/wait-2.gif') no-repeat 0px 50%;width:230px;height:30px;"></div>
	</div>

    <script type="text/javascript">
        mini.parse();
        
        var loginWindow = mini.get("loginWindow");
        loginWindow.show();

        function onLoginClick(e) {
            var form = new mini.Form("#loginWindow");
            form.validate();
            if (form.isValid() == false) return;
            loginWindow.hide();
            //mini.loading("登录成功，马上转到系统...", "登录成功");
            //setTimeout(function () {window.location = "web/main.jsp";}, 1500);
            var htmlContent = document.getElementById("htmlContent");
            htmlContent.style.display = "";
	        mini.showMessageBox({
	            width: 250,
	            title: "验证登录",
	            message: "验证登录",
	            showCloseButton:false,
	            html: htmlContent
	        });
	        setTimeout(function () {
	        	mini.hideMessageBox();
	        	window.location = "web/main.jsp";}, 3000
	        );
        }
        
        function onResetClick(e) {
            var form = new mini.Form("#loginWindow");
            form.clear();
        }

        function isEmail(s) {
            if (s.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
                return true;
            else
                return false;
        }

        function onUserNameValidation(e) {
            return true;
            //TODO 
            if (e.isValid) {
                if (isEmail(e.value) == false) {
                    e.errorText = "邮件格式不对";
                    e.isValid = false;
                }
            }
        }

        function onPwdValidation(e) {
        	return true;
            //TODO 
            if (e.isValid) {
                if (e.value.length < 5) {
                    e.errorText = "密码不能少于5个字符";
                    e.isValid = false;
                }
            }
        }
    </script>
  </body>
</html>
